local wuwu = fk.CreateSkill{
    name = "rmt__wuwu",
}
Fk:loadTranslationTable{
    ["rmt__wuwu"] = "呜呜",
    [":rmt__wuwu"] = "你的伤害牌或装备牌进入弃牌堆时，若之未造成伤害，你可以呜呜并摸一张牌。",
}

wuwu:addEffect(fk.AfterCardsMove, {
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(wuwu.name) then
            local room = player.room
            local move_event = room.logic:getCurrentEvent()
            local parent_event = move_event.parent
            local card_ids = {}
            if parent_event ~= nil then
                if parent_event.event == GameEvent.UseCard or parent_event.event == GameEvent.RespondCard then
                    local parent_data = parent_event.data
                    if parent_data.from == player and not parent_data.damageDealt then
                        card_ids = room:getSubcardsByRule(parent_data.card)
                    end
                elseif parent_event.event == GameEvent.Pindian then
                    local pindianData = parent_event.data
                    if pindianData.from == player then
                        card_ids = room:getSubcardsByRule(pindianData.fromCard)
                    else
                        for toId, result in pairs(pindianData.results) do
                            if player == toId then
                                card_ids = room:getSubcardsByRule(result.toCard)
                                break
                            end
                        end
                    end
                end
            end
            for _, move in ipairs(data) do
                if move.toArea == Card.DiscardPile then
                    if move.from == player then
                        for _, info in ipairs(move.moveInfo) do
                            local card = Fk:getCardById(info.cardId)
                            if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip) and
                            (card.type == Card.TypeEquip or card.is_damage_card) then
                                return true
                            end
                        end
                    elseif #card_ids > 0 then
                        for _, info in ipairs(move.moveInfo) do
                            local card = Fk:getCardById(info.cardId)
                            if info.fromArea == Card.Processing and table.contains(card_ids, info.cardId) and
                            (card.type == Card.TypeEquip or card.is_damage_card) then
                                return true
                            end
                        end
                    end
                end
            end
        end
    end,
    on_use = function (self, event, target, player, data)
        player:chat("呜呜")
        player:drawCards(1,wuwu.name)
    end,
})

return wuwu